<html lang="zh-cn">
<head>
{% include "tdm_include_head_template.html" %}
<script type="text/javascript">
$(function() {
  $("#city_select").change(function() {
    window.location.href="/tdm/admin/venue/"+$("#city_select").val();
  });
});
</script>
</head>

<body class=" theme-blue">
{% include "tdm_include_navbar_template.html" %}

<div class="container">
  <br/>
  {% include "tdm_include_error_template.html" %}

  {% include "tdm_include_admin_page_template.html" %}

  <div class="form-context">
  <form name="venue_form" class="form-horizontal" role="form" action="/tdm/admin/venue/{{view_city.name}}/" method="post">
    <div class="row">
      <div class="col-md-3">
        <select name="city_select" id="city_select" class="form-control">
          {% for city in city_all %}
          <option value="{{city.name}}" {% ifequal city.name view_city.name %}selected="selected"{% endifequal %}>{{city.name}}</option>
          {% endfor %}
        </select>
      </div>
    </div>
    <br>
    <table id="venue" class="table table-hover">
      <tr>
        <th>城市</th>
        <th>服务中心</th>
        <th>教学点</th>
        <th>教学点ID</th>
        <th>电源</th>
        <th>网络</th>
        <th>服务器</th>
        <th>移动</th>
        <th>考勤</th>
        <td>
          <button name="op" value="venue_enable" type="submit" class="btn btn-primary btn-sm">启用</button>
          <button name="op" value="venue_disable" type="submit" class="btn btn-primary btn-sm">停用</button>
        </td>
      </tr>
      {% for venue in venue_all %}
      <tr>
        <td>{{view_city.name}}</td>
        <td>{{venue.service_name}}</td>
        <td>{% if venue.disabled %}<span class="label label-default">停</span>{% endif %}{{venue.name}}</td>
        <td class="equidistant">{{venue.venue_id}}</td>
        <td><a href="/tdm/admin/power/{{view_city.name}}/{{venue.name}}/">{{venue.power_devs|length}}</a></td>
        <td><a href="/tdm/admin/network/{{view_city.name}}/{{venue.name}}/">{{venue.network_devs|length}}</a></td>
        <td><a href="/tdm/admin/server/{{view_city.name}}/{{venue.name}}/">{{venue.server_devs|length}}</a></td>
        <td><a href="/tdm/admin/mdm/{{view_city.name}}/{{venue.name}}/">{{venue.mdm_devs|length}}</a></td>
        <td><a href="/tdm/admin/acard/{{view_city.name}}/{{venue.name}}/">{{venue.ctm_devs|length}}</a></td>
        <td><input type="checkbox" name="venue_list" value="{{venue.venue_id}}"></td>
      </tr>
      {% endfor %}
      <tr>
        <td>
          <label for="city" class="sr-only">城市</label>
          <input name="city" type="text" class="form-control" id="city" value="{{view_city.name}}" style="width:60px;" readonly>
        </td>
        <td>
          <label for="service_name" class="sr-only">服务中心</label>
          <input name="service_name" type="text" class="form-control" id="service_name" style="width:80px;" placeholder="服务中心">
        </td>
        <td>
          <label for="venue" class="sr-only">教学点</label>
          <input name="venue" type="text" class="form-control" id="venue" style="width:100px;" placeholder="教学点">
        </td>
        <td>
          <label for="venue_id" class="sr-only">教学点ID</label>
          <input name="venue_id" type="text" class="form-control" id="venue_id" placeholder="教学点ID">
        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>
          <button name="op" value="venue_add" type="submit" class="btn btn-primary btn-sm">添加</button>
          <button name="op" value="venue_del" type="submit" class="btn btn-primary btn-sm">删除</button>
        </td>
      </tr>
      <tr>
        <th colspan="9">合并教学点</th>
        <td>
          <button name="op" value="venuegroup_add" type="submit" class="btn btn-primary btn-sm">合并</button>
          <button name="op" value="venuegroup_del" type="submit" class="btn btn-primary btn-sm">解散</button>
        </td>
      </tr>
      {% for vg in venue_group_list %}
      <tr>
        <td colspan="9">
          {% for v in vg.venues %}
          <input type="text" readonly="" value="{{v.name}}" class="form-control"> 
          {% endfor %}
        </td>
        <td><input type="checkbox" name="vg_list" value="{{vg.id}}"></td>
      </tr>
      {% endfor %}
    </table>
  </form>
  </div>

{% include "tdm_include_footer_template.html" %}
</div>
</body>
</html>